<script>
import axios from 'axios';

export default {
  // 获取所有用户列表
  async listUsers() {
    try {
      const response = await axios.get('/user/list');
      return response.data;
    } catch (error) {
      console.error('获取用户列表失败:', error);
      throw error;
    }
  },

  // 添加新用户
  async addUser(user) {
    try {
      const response = await axios.post('/user/add', user);
      return response.data;
    } catch (error) {
      console.error('添加用户失败:', error);
      throw error;
    }
  },

  // 获取指定小组的所有用户
  async getUsersBySquadId(squadId) {
    try {
      const response = await axios.get(`/user/squad/${squadId}`);
      return response.data;
    } catch (error) {
      console.error('获取小组用户列表失败:', error);
      throw error;
    }
  }
}
</script>
